class RegistrationController < ApplicationController
 
  layout "registration"


  
  def step1

  end

  def step2

      @university                            = University.find_by_name(params[:user][:university])
      @user                                  = User.new
      @user.name                             = params[:user][:name]
      @user.password                         = params[:user][:password]
      @user.full_name                        = params[:user][:full_name]
      @user.email                            = params[:user][:email]
      if params[:student]==1
      @user.university_email                 = params[:user][:university_email]
      @user.user_type_id                     = 1
#      else
#      @user.user_type_id                     = 2
      end
      @user.mobile_no                        = params[:user][:mobile_no]
      @user.university_id                    = @university.id
      @user.user_interests                   = params[:interests]
      @user.save
  
  end
  def student_registration_form
   @user_type         = UserType.find_by_stripped_name(params[:user_type])
   @categories        = UserTypeCategoryMap.find(:all, :conditions=>"user_type_id="+@user_type.id.to_s+" and relation_type=0",:order=>"category_id asc")
   render  :layout=>false
  end
  def service_provider_registration_form
   
   @categories        = UserTypeCategoryMap.find(:all, :conditions=>"user_type_id!=1 and relation_type=0",:order=>"category_id asc")
   render  :layout=>false
  end
  def check_email
   @email             = User.count_by_sql("select count(*) from users where email='"+params[:email]+"'")
   if @email >0
     flash[:message]="<font color=#ff0000>Email already exists. Please use a different E-mail Id or request for password! </font>"
   else
     flash[:message]="<font color=green>Email Address Available!</font>"
   end
   render  :layout=>false
  end
end
